home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / PG PRO⁄PG Lite Demos / PG Writer π / PG PRO.INCL < prev    next >
Text File  |  1994-03-28  |  64KB  |  1,793 lines

  1. '===============================================================================
  2. '=                         Copyright 1992 Staz™ Software, Inc.                 =
  3. '=              All rights reserved  / "PG PRO.INCL" from PG:PRO II            =
  4. '===============================================================================
  5. INCLUDE FILE _aplIncl
  6. COMPILE 0,_MacsbugLabels_strResource_caseInsensitive'set by PG:PRO
  7. GLOBALS "PG PRO.GLBL"'include standard global file
  8. END GLOBALS'no other globals
  9. DEFSTR LONG
  10. GOTO "PG:Start"
  11. '_______________________________________________________________________________
  12. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ALERTS/DIALOGS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  13. '———————————————————————————————————————————————————————————————————————————————
  14. '_______________________________________________________________________________
  15. LOCAL FN pGcntrRes(type&,resID)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  16. '—————————————————————————————————————————————————————————————————————————————
  17. DIM t,l,b,r'local rect
  18. CURSOR _arrowCursor'reset arrow cursor
  19. hndl& = FN GETRESOURCE(type&,resID)'handle to alert resource
  20. LONG IF hndl&'got a handle?
  21. t;8 = [hndl&]'copy alert's rect
  22. CALL OFFSETRECT(t,-l,-t)'center it
  23. CALL OFFSETRECT(t,gScrnR/2-r/2,{_mBarHeight}+gScrnB/3-b/3)
  24. BLOCKMOVE @t,[hndl&],8'modify the resource
  25. END IF
  26. END FN
  27. '_______________________________________________________________________________
  28. LOCAL FN pGshowErr(errorNum)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  29. '—————————————————————————————————————————————————————————————————————————————
  30. DIM pTxt$(3)'holds message strings
  31. '## Description ---------- ## Description ---------- ## Description ----------
  32. '01 Add/Chg res failed     05 couldn't save pG3c res 09 used pGbuild(0)
  33. '02 couldn't get pG3w res  06 name of PG PRO app     10 used pGclose(0)
  34. '03 couldn't save pG3w res 07 paste too big for fld  11 your codes start here
  35. '04 couldn't get pG3c res  08 too many chars in fld  00 You CALL PARAMTEXT!
  36. '## Description ---------- ## Description ---------- ## Description ----------
  37. FN pGcntrRes(_"ALRT",_baseID-1)'center the error alert window
  38. LONG IF errorNum
  39. pTxt$(1) = STR#(_baseID-1,errorNum)'error message from STR#
  40. pTxt$(2) = MID$(STR$(errorNum),2)'error number from entry param
  41. pTxt$(3) = STR#(_baseID-1,6)'error message from STR#
  42. CALL PARAMTEXT(pTxt$(1),pTxt$(2),pTxt$(3),"")'set up text for alert
  43. END IF
  44. x = FN ALERT(_baseID-1,0)'show the alert
  45. END FN
  46. '_______________________________________________________________________________
  47. LOCAL FN pGgetText$(theDialog&,theItem)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  48. '—————————————————————————————————————————————————————————————————————————————
  49. DIM t;8'local DIMs
  50. CALL GETDITEM(theDialog&,theItem,itemType,itemHandle&,t)
  51. CALL GETITEXT(itemHandle&,theText$)'get the text
  52. END FN = theText$'return simple string
  53. '_______________________________________________________________________________
  54. LOCAL FN pGsetText(theDialog&,theItem,theText$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  55. '—————————————————————————————————————————————————————————————————————————————
  56. DIM t;8'local DIMs/get this item
  57. CALL GETDITEM(theDialog&,theItem,itemType,itemHandle&,t)
  58. CALL SETITEXT(itemHandle&,theText$)'get the text
  59. CALL SELITEXT(theDialog&,theItem,0,[itemHandle&]+_TELength)
  60. END FN
  61. '_______________________________________________________________________________
  62. LOCAL FN pGframeBtn(theDialog&,theItem)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  63. '—————————————————————————————————————————————————————————————————————————————
  64. CALL SETPORT(theDialog&)'allow drwg before MODALDIALOG
  65. DIM t;8'local DIMs/get this item
  66. CALL GETDITEM(theDialog&,theItem,itemType,itemHandle&,t)
  67. CALL INSETRECT(t,-4,-4)'expand rect
  68. CALL PENNORMAL:PEN 3,3'3x3 pen
  69. LONG IF PEEK([itemHandle&]+_contrlHilite)=255'btn disabled
  70. CALL PENPAT(#REGISTER(A5)-28)'make it gray
  71. END IF'
  72. CALL FRAMEROUNDRECT(t,16,16)'frame it
  73. CALL PENNORMAL'restore pen
  74. END FN
  75. '_______________________________________________________________________________
  76. LOCAL FN pGask$(theQuestion$,theAnswer$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  77. '—————————————————————————————————————————————————————————————————————————————
  78. theWindow = WINDOW(_activeWnd)'record current window
  79. CALL GETPORT(oldPort&)
  80. FN pGcntrRes(_"DLOG",_baseID - 2)'center the dialog
  81. CALL PARAMTEXT(theQuestion$,"","","")'show the prompt
  82. theDialog& = FN GETNEWDIALOG(_baseID - 2,0,-1)'get & disp the resource
  83. FN pGsetText(theDialog&,3,theAnswer$):theAnswer$=""'default answer
  84. FN pGframeBtn(theDialog&,1)'frame the OK btn
  85. DO'here we go
  86. CALL MODALDIALOG(0,hitItem)'cycle till OK/Cancel clicked
  87. UNTIL hitItem < 3'
  88. LONG IF hitItem = 1'was it OK?
  89. theAnswer$ = FN pGgetText$(theDialog&,3)'yes, return the answer
  90. IF theAnswer$="" THEN theAnswer$=" "'send a space if OK'd null
  91. END IF
  92. CALL DISPOSDIALOG(theDialog&)'all done
  93. LONG IF theWindow
  94. WINDOW(theWindow)'restore active window
  95. XELSE
  96. IF oldPort& THEN CALL SETPORT(oldPort&)
  97. END IF
  98. END FN = theAnswer$
  99. '_______________________________________________________________________________
  100. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ RESOURCE  FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  101. '———————————————————————————————————————————————————————————————————————————————
  102. '_______________________________________________________________________________
  103. LOCAL FN pGreplaceRes(resHndl&,resTp&,resID,resName$)'∑∑œœœœœœœœœœœœœœœœœœœœœ∑∑
  104. '—————————————————————————————————————————————————————————————————————————————
  105. LONG IF resHndl&
  106. hndlFlags = FN HGETSTATE(resHndl&)'get state of new handle
  107. LONG IF hndlFlags AND _resource%'!! tried to send res hndl!!
  108. OSErr = FN HNOPURGE(resHndl&)'don't allow purge during copy
  109. newHndl& = FN HANDTOHAND(resHndl&)'duplicate the handle
  110. OSErr = FN HSETSTATE(resHndl&,hndlFlags)'restore orig state
  111. resHndl& = newHndl&'now use the new hndl
  112. END IF
  113. END IF
  114. LONG IF resHndl&
  115. curRes = FN CURRESFILE'record current res reference
  116. CALL USERESFILE(gResRef)'use output file
  117. oldRes& = FN GET1RESOURCE(resTp&,resID)'check for existing res
  118. LONG IF oldRes&'got one?
  119. hndlFlags = FN HGETSTATE(oldRes&)'save current handle info
  120. OSErr = FN HUNLOCK(oldRes&)'unlock it
  121. OSErr = FN HNOPURGE(oldRes&)'don't allow purge
  122. theSize& = FN GETHANDLESIZE(resHndl&)'get new size
  123. OSErr = FN SETHANDLESIZE(oldRes&,theSize&)'resize old to match
  124. BLOCKMOVE [resHndl&],[oldRes&],theSize&'replace old data
  125. OSErr = FN HSETSTATE(oldRes&,hndlFlags)'restore handle info
  126. OSErr = FN HNOPURGE(oldRes&)'don't allow purge
  127. CALL CHANGEDRESOURCE(oldRes&)'mark it as changed
  128. OSErr = FN DISPOSHANDLE(resHndl&)'dump the duplicate hndl
  129. LONG IF LEN(resName$)
  130. CALL SETRESINFO(oldRes&,resID,resName$)
  131. END IF
  132. XELSE'otherwise, just add it
  133. CALL ADDRESOURCE(resHndl&,resTp&,resID,resName$)'add it
  134. CALL SETRESATTRS(resHndl&,_resPurgeable%)'make it purgable
  135. CALL CHANGEDRESOURCE(resHndl&)'mark change(after SETRESATTRS)
  136. OSErr = _noERR
  137. END IF'
  138. CALL USERESFILE(curRes)'restore orig file
  139. LONG IF FN RESERROR OR OSErr'any problems?
  140. FN pGshowErr(1)'my error code for failure
  141. END IF
  142. END IF
  143. END FN
  144. '_______________________________________________________________________________
  145. LOCAL FN pGreplaceXRes(resHndl&,resTp&,resID,resName$,resRef)'∑∑œœœœœœœœœœœœœ∑∑
  146. '—————————————————————————————————————————————————————————————————————————————
  147. oldRes = gResRef'record old res file ref
  148. gResRef = resRef'temp switch to new
  149. FN pGreplaceRes(resHndl&,resTp&,resID,resName$)'save res in new file
  150. gResRef = oldRes'switch back to orig file
  151. END FN
  152. '_______________________________________________________________________________
  153. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ OBJECT  FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  154. '———————————————————————————————————————————————————————————————————————————————
  155. '_______________________________________________________________________________
  156. LOCAL FN pGcountObj(objListID)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  157. '—————————————————————————————————————————————————————————————————————————————
  158. resHndl& = FN GETRESOURCE(_"pG3c",objListID)'handle to wnd cntrl resource
  159. LONG IF resHndl&'valid handle?
  160. objCount = {[resHndl&]}'obj count is first word of res
  161. XELSE'no handle?
  162. FN pGshowErr(4)'tell user something's wrong
  163. objCount = 0'send back zero count
  164. END IF'
  165. END FN = objCount'FN result is num of elements
  166. '_______________________________________________________________________________
  167. LOCAL FN pGgetObj(objListID,objElem)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  168. '—————————————————————————————————————————————————————————————————————————————
  169. resHndl& = FN GETRESOURCE(_"pG3c",objListID)'handle to wnd cntrl resource
  170. LONG IF resHndl&'valid handle?
  171. DEC(objElem)'allow for OCNT
  172. offSet& = 2 + objElem * _objRecSz'calc offset to correct element
  173. gObject = [resHndl&]+offSet&'blkmove to global record
  174. XELSE'no handle?
  175. FN pGshowErr(4)'tell user something's wrong
  176. END IF'
  177. END FN
  178. '_______________________________________________________________________________
  179. LOCAL FN pGputObj(objListID,objElem)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  180. '—————————————————————————————————————————————————————————————————————————————
  181. resHndl& = FN GETRESOURCE(_"pG3c",objListID)'handle to wnd cntrl resource
  182. LONG IF resHndl&'valid handle?
  183. OSErr  = FN HNOPURGE(resHndl&)
  184. DEC(objElem)'allow for OCNT
  185. offSet& = 2 + objElem * _objRecSz'calc offset to correct element
  186. BLOCKMOVE @gObjSel,[resHndl&]+offSet&,_objRecSz'blkmove to resource
  187. CALL CHANGEDRESOURCE(resHndl&)'mark it as changed
  188. XELSE'no handle?
  189. FN pGshowErr(5)'tell user something's wrong
  190. END IF
  191. END FN
  192. '_______________________________________________________________________________
  193. LOCAL FN pGgetRef(objListID,theRef)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  194. '—————————————————————————————————————————————————————————————————————————————
  195. theCount = FN pGcountObj(objListID)'number of objects
  196. element  = 0'element not yet found
  197. LONG IF theCount'non-zero count?
  198. FOR loop = 1 TO theCount'loop thru object list
  199. FN pGgetObj(objListID,loop)'get this object
  200. LONG IF gObjKind <> _graphicObj'ref not valid on graphics
  201. LONG IF ABS(gObjRef) = ABS(theRef)'matches reference?
  202. element = loop'record element
  203. loop    = theCount'shortcut the loop
  204. END IF'
  205. END IF
  206. NEXT
  207. END IF'
  208. END FN = element'global record filled on return
  209. '_______________________________________________________________________________
  210. LOCAL FN pGpointInObj'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  211. '—————————————————————————————————————————————————————————————————————————————
  212. DIM t;8
  213. theObject = 0
  214. objCount  = FN pGcountObj(gWhichClass)'get num of objs in list
  215. LONG IF objCount'non zero?
  216. resHndl&  = FN GETRESOURCE(_"pG3c",gWhichClass)
  217. FOR loop  = objCount-1 TO 0 STEP - 1'loop thru backwards
  218. offSet& = 2  + loop * _objRecSz
  219. t;8     = [resHndl&] + offSet& + 6
  220. LONG IF FN PTINRECT(gMouseY,t)'clicked here?
  221. theObject = loop + 1'set return value to this obj
  222. loop  = 0'jump the loop
  223. END IF
  224. NEXT
  225. END IF
  226. END FN = theObject
  227. '_______________________________________________________________________________
  228. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ DRAWING  FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  229. '———————————————————————————————————————————————————————————————————————————————
  230. '_______________________________________________________________________________
  231. LOCAL FN pGdepthOfPoint(my,mx)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  232. '—————————————————————————————————————————————————————————————————————————————
  233. inColor = _false
  234. LONG IF SYSTEM(_macPlus) = _false
  235. CALL LOCALTOGLOBAL(my)
  236. gdHndl& = FN GETDEVICELIST
  237. WHILE gdHndl&
  238. LONG IF FN PTINRECT(my,#[gdHndl&]+_gdRect)
  239. IF {[[[gdHndl&]+_gdpMap]]+_pmPixelSize} > 2 THEN inColor = _zTrue
  240. gdHndl& = 0
  241. END IF
  242. IF gdHndl& THEN gdHndl& = FN GETNEXTDEVICE(gdHndl&)
  243. WEND
  244. END IF
  245. END FN = inColor
  246. '_______________________________________________________________________________
  247. CLEAR LOCAL
  248. LOCAL FN pGblackAndWhite'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  249. '—————————————————————————————————————————————————————————————————————————————
  250. DIM RECORD aWndRec'auxiliary window rec
  251. DIM setCPat  ,aWndCPatID
  252. DIM setBWPat ,aWndBWPatID
  253. DIM setRGB   ,aWndRGBrec;6
  254. DIM aWndType&,aWndRefCon&
  255. DIM setFont  ,aWndFSize,aWndFMode,aWndFFace
  256. DIM setSpare ,aWndData;40,aWndDCODID
  257. DIM aWndRsrv1&,aWndRsrv2&
  258. DIM 60 aWndFontName$
  259. DIM END RECORD _aWndSz
  260.  
  261. CALL PENNORMAL'fix pen
  262. CALL FORECOLOR(33)
  263. CALL BACKCOLOR(30)
  264.  
  265. resHndl& = FN GETRESOURCE(_"pG3*",gWhichClass)
  266. LONG IF resHndl&
  267. BLOCKMOVE [resHndl&],@aWndRec,_aWndSz
  268. inColor = FN pGdepthOfPoint(WINDOW(3)/2,WINDOW(2)/2)
  269. LONG IF inColor'not black & white?
  270. LONG IF setCPat
  271. ppat& = FN GETPIXPAT(aWndCPatID)
  272. LONG IF ppat&
  273. CALL BACKPIXPAT(ppat&)
  274. END IF
  275. END IF
  276. LONG IF setRGB
  277. CALL RGBBACKCOLOR(aWndRGBrec)
  278. END IF
  279. XELSE'black & white
  280. LONG IF setBWPat
  281. pat& = FN GETPATTERN(aWndBWPatID)
  282. `       BEQ.S   noPat
  283. `       MOVE.L  D0,A0
  284. `       MOVE.L  (A0),-(SP)
  285. `       _backPat
  286. `noPat
  287. END IF
  288. END IF
  289. LONG IF setFont'default font
  290. LONG IF WINDOW(_outputWnd)
  291. CALL GETFNUM(aWndFontName$,fNum)
  292. TEXT fNum,aWndFSize,aWndFFace,aWndFMode-1
  293. END IF
  294. END IF
  295. END IF
  296.  
  297. END FN
  298. '_______________________________________________________________________________
  299. LOCAL FN pGuseObjColor'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  300. '—————————————————————————————————————————————————————————————————————————————
  301. LONG IF gScreenDepth > 1'not black & white?
  302. CALL RGBFORECOLOR(gObjFRed)'use object's forecolor
  303. CALL RGBBACKCOLOR(gObjBRed)'use object's backcolor
  304. END IF
  305. END FN
  306. '_______________________________________________________________________________
  307. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ CONTROL FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  308. '———————————————————————————————————————————————————————————————————————————————
  309. '_______________________________________________________________________________
  310. LOCAL FN pGfixEditor'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  311. '—————————————————————————————————————————————————————————————————————————————
  312. DIM t,l,b,r
  313. LONG IF WINDOW(_EFnum) = 8001'is this a Text Editor?
  314. FN pGgetRef(WINDOW(_outputWClass),8001)
  315. LONG IF gObjAutoReSz
  316. t;8 = WINDOW(_wndPointer)+_portRect'get window's rect
  317. r=r-15:b=b-17'inset for scroll bars
  318.  
  319. LONG IF BUTTON&(8000)
  320. wd = {[PRHANDLE] + _prInfo + _rPage + _right}
  321. SCROLL BUTTON 8000,,,wd,wd/5
  322. TEHndl& = TEHANDLE(8001)
  323. LONG IF TEHndl&
  324. BLOCKMOVE @t,[TEHndl&]+8,8
  325. oldR = r
  326. r = l + wd + 34
  327. CALL OFFSETRECT(t,-BUTTON(8000)+_TEWndInset,0)
  328. BLOCKMOVE @t,[TEHndl&],8
  329. r = oldR
  330. CALL TECALTEXT(TEHndl&)
  331. CALL TEUPDATE(t,TEHndl&)
  332. END IF
  333. XELSE
  334. CALL INSETRECT(t,_TEWndInset,_TEWndInset)
  335. EDIT FIELD 8001,,@t
  336. END IF
  337.  
  338. LONG IF BUTTON&(8001)'vert scroll present?
  339. rowCnt = ((b-t) >> 4) - 2'calc an avg row count
  340. SCROLL BUTTON 8001,,,,rowCnt'reset pg up/down
  341. END IF
  342.  
  343. END IF
  344. END IF
  345. END FN
  346. '_______________________________________________________________________________
  347. LOCAL FN pGdrawControls'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  348. '—————————————————————————————————————————————————————————————————————————————
  349. theCount = FN pGcountObj(gWhichClass)'count objects in window
  350. cBackPat = FN pGblackAndWhite
  351. firstFld = 0
  352. LONG IF theCount'non-zero?
  353. '
  354. FOR loop = 1 TO theCount'fields before scroll bars
  355. FN pGgetObj(gWhichClass,loop)'get next object
  356.  
  357. LONG IF gObjKind = _pictObj'it's a pict field
  358. LONG IF gObjResID'picture included?
  359. PICTURE FIELD gObjRef,%gObjResID,@gObjT,gObjZType,gObjZJust
  360. XELSE'no picture
  361. PICTURE FIELD gObjRef,"",@gObjT,gObjZType,gObjZJust
  362. END IF
  363. END IF'end of pict obj
  364.  
  365. LONG IF gObjKind = _styleObj'styled text field?
  366. gObjZJust = gObjZJust + (gObjFRed<<2)
  367. LONG IF gObjResID'existing text?
  368. resHndl& = FN GETRESOURCE(_"pG3t",gObjResID)
  369. LONG IF resHndl&
  370. EDIT FIELD -gObjRef,&resHndl&,(gObjL,gObjT)-(gObjR,gObjB),gObjZType,gObjZJust
  371. END IF
  372. XELSE'build it blank
  373. EDIT FIELD -gObjRef,"",@gObjT,gObjZType,gObjZJust
  374. END IF'NOTE: fields built 1st to allow
  375.  
  376. LONG IF firstFld = 0
  377. LONG IF ((gObjZType-1) AND &X1100)=0'not a static or gray field
  378. LONG IF gObjRef < 8000
  379. firstFld = gObjRef
  380. END IF
  381. END IF
  382. END IF'attachment to scroll bars
  383.  
  384. LONG IF firstFld = 0
  385. LONG IF ((gObjZType-1) AND &X1100)=0'not a static or gray field
  386. LONG IF gObjRef < 8000
  387. firstFld = gObjRef
  388. END IF
  389. END IF
  390. END IF
  391. END IF'end of _styleObj
  392.  
  393. NEXT
  394. '
  395. FOR loop = 1 TO theCount'scroll bars before lists
  396. FN pGgetObj(gWhichClass,loop)'get next object
  397. LONG IF gObjKind = _scrollObj'scroll bar?
  398. LONG IF ABS(gObjSel) <>1'part of a group?
  399. group = gObjSel'record current group
  400. attachedRef = 0
  401. FOR stylLoop = 1 TO theCount'loop thru obj list
  402. LONG IF stylLoop <> loop'not the same object
  403. FN pGgetObj(gWhichClass,stylLoop)'get obj record
  404. LONG IF group = gObjSel'part of same group?
  405. LONG IF gObjKind = _styleObj'styled field?
  406. attachedRef = -gObjRef'attach button to style field
  407. stylLoop = theCount'short cut rest of the loop
  408. END IF
  409. END IF
  410. END IF
  411. NEXT
  412. FN pGgetObj(gWhichClass,loop)'reload old record
  413. LONG IF attachedRef'was there a matching field?
  414. gObjRef = attachedRef'yes, change this reference
  415. END IF
  416. END IF
  417. SCROLL BUTTON gObjRef,gObjCtrlVal,gObjMin,gObjMax,gObjPgUpDn,@gObjT,gObjZType
  418. END IF'attachment to scroll bars
  419. NEXT
  420. '
  421. FOR loop = 1 TO theCount'loop thru list
  422. FN pGgetObj(gWhichClass,loop)'get next object
  423. SELECT gObjKind'what kind is it?
  424. CASE _styleObj,_pictObj'fields already built
  425. CASE _scrollObj'scroll bars already built
  426. CASE _buttonObj'it's a button
  427. LONG IF gObjZType
  428. objText$ = STR#(_baseID,gObjElement)
  429. BUTTON gObjRef,gObjCtrlVal,objText$,@gObjT,gObjZType
  430. XELSE
  431. gSubAction = _otherUserInit'set flag to init obj
  432. gWhichObjElem = loop
  433. oldWClass = gWhichClass
  434. GLOBALS GOSUB "PG:Any Other"
  435. gWhichClass = oldWClass
  436. FN pGblackAndWhite'user may have chgd bkgnd
  437. END IF
  438. CASE _listObj'it's a scrolling list
  439. resHndl& = FN GETRESOURCE(_"STR#",gObjResID)
  440. LONG IF resHndl&
  441. CALL GETRESINFO(resHndl&,ID,tp&,objText$)
  442. TEXT gObjLFont,gObjLSize,0,0
  443. SWAP gObjFBlue,gObjBlue
  444. IF gScreenDepth > 1 THEN CALL RGBFORECOLOR(gObjFRed)
  445. SWAP gObjFBlue,gObjBlue
  446. BUTTON gObjRef,gObjResID,objText$,@gObjT,gObjZType
  447. END IF
  448. END SELECT
  449. NEXT'next object
  450. END IF
  451. LONG IF firstFld'got an active field
  452. EDIT FIELD firstFld'activate it
  453. SETSELECT 0,WINDOW(_EFTextLen)'select all its text
  454. END IF
  455. END FN
  456. '_______________________________________________________________________________
  457. LOCAL FN pGsetGroup(theRef)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  458. '—————————————————————————————————————————————————————————————————————————————
  459. selectedBtn = 0'default result = none
  460. element = FN pGgetRef(gWhichClass,theRef)'get the referenced element
  461. LONG IF element'got it?
  462. LONG IF gObjKind = _buttonObj'is it a button?
  463. LONG IF ABS(gObjSel) > 1'part of a group?
  464. LONG IF gObjZType = 3'a radio button?
  465. theGroup = gObjSel'this is the group we need
  466. theCount = FN pGcountObj(gWhichClass)'number of objects
  467. FOR loop = 1 TO theCount'loop thru list
  468. FN pGgetObj(gWhichClass,loop)'get this obj
  469. LONG IF gObjSel = theGroup'right group?
  470. LONG IF gObjKind = _buttonObj'is it a button?
  471. LONG IF gObjZType = 3'a radio button?
  472. LONG IF gObjRef = theRef'set this one?
  473. BUTTON gObjRef,2
  474. XELSE
  475. LONG IF BUTTON(gObjRef) = 2'don't mess with disabled btns
  476. BUTTON gObjRef,1
  477. END IF
  478. END IF
  479. END IF
  480. END IF
  481. END IF
  482. NEXT loop
  483. END IF
  484. END IF
  485. END IF
  486. END IF
  487. END FN
  488. '_______________________________________________________________________________
  489. LOCAL FN pGgetGroup(theRef)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  490. '—————————————————————————————————————————————————————————————————————————————
  491. selectedBtn = 0'default result = none
  492. element = FN pGgetRef(gWhichClass,theRef)'get the referenced element
  493. LONG IF element'got it?
  494. LONG IF gObjKind = _buttonObj'is it a button?
  495. LONG IF ABS(gObjSel) > 1'part of a group?
  496. LONG IF gObjZType = 3'a radio button?
  497. theGroup = gObjSel'this is the group we need
  498. theCount = FN pGcountObj(gWhichClass)'number of objects
  499. FOR loop = 1 TO theCount'loop thru list
  500. FN pGgetObj(gWhichClass,loop)'get this obj
  501. LONG IF gObjSel = theGroup'right group?
  502. LONG IF gObjKind = _buttonObj'is it a button?
  503. LONG IF gObjZType = 3'a radio button?
  504. LONG IF BUTTON(gObjRef) = 2'is it set?
  505. selectedBtn = gObjRef'gotcha
  506. loop = theCount'skip the rest of the loop
  507. END IF
  508. END IF
  509. END IF
  510. END IF
  511. NEXT loop
  512. END IF
  513. END IF
  514. END IF
  515. END IF
  516. END FN = selectedBtn
  517. '_______________________________________________________________________________
  518. LOCAL FN pGbtnAction(theRef)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  519. '—————————————————————————————————————————————————————————————————————————————
  520. DIM t,l,b,r
  521. gDblClick = _false
  522. LONG IF theRef = 8000
  523. FN pGfixEditor
  524. XELSE
  525. element = FN pGgetRef(gWhichClass,theRef)'get btn's obj record
  526. LONG IF element'found the record?
  527. SELECT gObjKind
  528. CASE _scrollObj'a scroll button?
  529. t;8 = @gObjT'record it's rect
  530. theGroup = gObjSel
  531. LONG IF ABS(theGroup)>1
  532. theCount = FN pGcountObj(gWhichClass)'number of objects
  533. FOR loop = 1 TO theCount'loop thru list
  534. FN pGgetObj(gWhichClass,loop)'get this obj
  535. LONG IF gObjSel = theGroup
  536. LONG IF gObjKind = _listObj'scrolling list?
  537. LONG IF gObjT=t AND gObjR=l+1'next to this scroll bar?
  538. LONG IF BUTTON&(gObjRef)
  539. LONG IF {[[[BUTTON&(gObjRef)]+_contrlData]]} <> BUTTON(theRef)-1
  540. %[[[BUTTON&(gObjRef)]+_contrlData]],BUTTON(theRef)-1
  541. INC(gObjB):CALL CLIPRECT(gObjT)'add to clip & redraw
  542. CALL DRAW1CONTROL(BUTTON&(gObjRef))
  543. BUTTON gObjRef,BUTTON(gObjRef)'restores autoclip
  544. END IF
  545. END IF
  546. loop = theCount'shortcut the loop
  547. END IF
  548. END IF
  549. END IF
  550. NEXT
  551. END IF
  552. CASE _buttonObj'regular button?
  553. SELECT gObjZType'what type?
  554. CASE 2'check box?
  555. LONG IF BUTTON(gObjRef) = 2'if it was selected
  556. BUTTON gObjRef,1'deselect it
  557. XELSE'otherwise
  558. BUTTON gObjRef,2'select it
  559. END IF
  560. CASE 3'radio button?
  561. LONG IF ABS(gObjSel) <> 1'should be part of a group
  562. theGroup = gObjSel'record group number
  563. theCount = FN pGcountObj(gWhichClass)'number of objects
  564. FOR loop = 1 TO theCount'loop thru list
  565. FN pGgetObj(gWhichClass,loop)'get this obj
  566. LONG IF gObjSel = theGroup'same group?
  567. LONG IF BUTTON(gObjRef)'only toggle active buttons
  568. LONG IF gObjRef = theRef'clicked button?
  569. BUTTON gObjRef,2'yes, select it
  570. XELSE'no
  571. BUTTON gObjRef,1'deselect it
  572. END IF
  573. END IF
  574. END IF
  575. NEXT
  576. END IF
  577. END SELECT
  578. CASE _listObj
  579. LONG IF FN TICKCOUNT <= gDblTime&
  580. LONG IF gDblRef = theRef
  581. LONG IF gDblWnd = gActiveWnd
  582. gDblClick = _zTrue
  583. END IF
  584. END IF
  585. END IF
  586. LONG IF gDblClick = _false
  587. IF _ignoreSnglClk THEN gAction = 0
  588. gDblRef   = theRef
  589. gDblTime& = FN TICKCOUNT + [_doubleTime]
  590. gDblWnd   = gActiveWnd
  591. XELSE
  592. gDblWnd   = 0
  593. END IF
  594. END SELECT
  595. END IF
  596. END IF
  597. FN pGblackAndWhite
  598. END FN
  599. '_______________________________________________________________________________
  600. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ WINDOW FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  601. '———————————————————————————————————————————————————————————————————————————————
  602. '_______________________________________________________________________________
  603. LOCAL FN pGgetWnd$(resID,recordPtr&)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  604. '—————————————————————————————————————————————————————————————————————————————
  605. resHndl& = FN GETRESOURCE(_"pG3w",resID)
  606. LONG IF resHndl&
  607. BLOCKMOVE [resHndl&],recordPtr&,FN GETHANDLESIZE(resHndl&)
  608. CALL GETRESINFO(resHndl&,resID,tp&,wTitle$)
  609. XELSE
  610. FN pGshowErr(2)
  611. wTitle$ = "ERROR"
  612. END IF
  613. END FN = wTitle$
  614. '_______________________________________________________________________________
  615. LOCAL FN pGputWnd(resID,recordPtr&)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  616. '—————————————————————————————————————————————————————————————————————————————
  617. resHndl& = FN GETRESOURCE(_"pG3w",resID)
  618. LONG IF resHndl&
  619. OSErr = FN HNOPURGE(resHndl&)
  620. LONG IF FN GETHANDLESIZE(resHndl&) >0
  621. BLOCKMOVE recordPtr&,[resHndl&],FN GETHANDLESIZE(resHndl&)
  622. CALL CHANGEDRESOURCE(resHndl&)
  623. END IF
  624. XELSE
  625. FN pGshowErr(3)
  626. END IF
  627. END FN
  628. '_______________________________________________________________________________
  629. LOCAL FN pGcalcWndGlobals'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  630. '—————————————————————————————————————————————————————————————————————————————
  631. gActWindow  = WINDOW(_activeWnd)
  632. gOutWindow  = WINDOW(_outputWnd)
  633. gWhichClass = WINDOW(_outputWClass)
  634. END FN
  635. '_______________________________________________________________________________
  636. LOCAL'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  637. DIM t;8
  638. LOCAL FN pGinsetWnd(t;8,theWndType,rectPtr&)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  639. '—————————————————————————————————————————————————————————————————————————————
  640. SELECT theWndType'what type of window is this?
  641. CASE 3,4 :CALL INSETRECT (t, 8, 8)'plain or shadow (8 pix border)
  642. CASE 2   :CALL INSETRECT (t,12,12)'modal dialog(8 pix gray+4 pix)
  643. CASE ELSE:CALL INSETRECT (t, 8, 8):t = t + 16'window with title bar
  644. END SELECT'done
  645. BLOCKMOVE @t,rectPtr&,8
  646. END FN'return with rect's addr
  647. '_______________________________________________________________________________
  648. LOCAL FN pGsetGrow'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  649. '—————————————————————————————————————————————————————————————————————————————
  650. DIM pGwT,pGwL,pGwB,pGwR,pGwKind,pGwAttrs,pGwMinX,pGwMinY
  651. DIM pGwMaxX,pGwMaxY,pGZmT,pGZmL,pGZmB,pGZmR
  652. DIM pGwHpg,pGwHMax,pGwVpg,pGwVMax,pGwRefCon&
  653.  
  654. wTitle$ = FN pGgetWnd$(gWhichClass,@pGwT)
  655. IF pGwMinX < 50 THEN pGwMinX = 50
  656. IF pGwMinY < 50 THEN pGwMinY = 50
  657. IF pGwMaxX < pGwMinX THEN pGwMaxX = 1000
  658. IF pGwMaxY < pGwMinY THEN pGwMaxY = 1000
  659.  
  660. MINWINDOW pGwMinX,pGwMinY
  661. MAXWINDOW pGwMaxX,pGwMaxY
  662. END FN
  663. '_______________________________________________________________________________
  664. LOCAL FN pGsetZoom'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  665. '—————————————————————————————————————————————————————————————————————————————
  666. DIM t,l,b,r,centerY,centerX
  667. DIM pGwT,pGwL,pGwB,pGwR,pGwKind,pGwAttrs,pGwMinX,pGwMinY
  668. DIM pGwMaxX,pGwMaxY,pGZmT,pGZmL,pGZmB,pGZmR
  669. DIM pGwHpg,pGwHMax,pGwVpg,pGwVMax,pGwRefCon&
  670.  
  671. wTitle$ = FN pGgetWnd$(gWhichClass,@pGwT)
  672.  
  673. LONG IF [@pGZmB]'custom zoom size
  674. t;8 = @pGZmT
  675. XELSE
  676. t;8 = @gScrnT'just copy the main scrn
  677. centerY = WINDOW(_height)>>1
  678. centerX = WINDOW(_width) >>1
  679. CALL LOCALTOGLOBAL(centerY)
  680. LONG IF SYSTEM(3) = 0'newer than a Mac plus
  681. gdHndl& =FN GETDEVICELIST'handle to 1st device in list
  682. DO
  683. t;8 = [gdHndl&]+_gdRect'get its rect
  684. LONG IF FN PTINRECT(centerY,t)'cntr of wnd in this monitor?
  685. gdHndl& = 0
  686. XELSE
  687. gdHndl& = FN GETNEXTDEVICE(gdHndl&)'get next scrn
  688. END IF'end of not main scrn
  689. UNTIL gdHndl& = 0
  690. END IF'end of not a max plus
  691. t = t + {_mBarHeight}'allow for the menu bar
  692. FN pGinsetWnd(@t,_docZoom,@t)'inset wnd as per window kind
  693. END IF
  694. SETZOOM gWhichWindow,@t
  695. END FN
  696. '_______________________________________________________________________________
  697. LOCAL FN pGupdate'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  698. '—————————————————————————————————————————————————————————————————————————————
  699. theCount = FN pGcountObj(WINDOW(_outputWClass))
  700. LONG IF theCount
  701. FOR loop = 1 TO theCount
  702. FN pGgetObj(WINDOW(_outputWClass),loop)
  703. LONG IF gObjKind = _graphicObj
  704. FN pGuseObjColor'set to this color
  705. LONG IF gObjZType'not a line
  706. LONG IF gObjFillPat > -1'shape is filled
  707. PEN 1,1,1,_patCopy,gObjFillPat'set fill pat
  708. SELECT gObjZType
  709. CASE 4:CALL PAINTRECT(gObjT)'filled box
  710. CASE 5:CALL PAINTROUNDRECT(gObjT,16,16)'filled rnd rect
  711. CASE 6:CALL PAINTOVAL(gObjT)'filled oval
  712. END SELECT
  713. END IF
  714.  
  715. PEN gObjRef,gObjRef,1,_patCopy,gObjLinePat
  716. SELECT gObjZType
  717. CASE 1,4:CALL FRAMERECT(gObjT)'box
  718. CASE 2,5:CALL FRAMEROUNDRECT(gObjT,16,16)'rnd rect
  719. CASE 3,6:CALL FRAMEOVAL(gObjT)'oval
  720. END SELECT
  721.  
  722. XELSE'it's a line
  723. PEN gObjRef,gObjRef,1,_patCopy,gObjLinePat
  724. CALL MOVETO(gObjL,gObjT)
  725. CALL LINETO(gObjR,gObjB)
  726. END IF
  727. XELSE
  728. LONG IF gObjKind = _buttonObj AND gObjZType = 0
  729. gSubAction    = _otherUserUpdate'set flag to draw obj
  730. gWhichObjElem = loop'record this element num
  731. FN pGcalcWndGlobals
  732. GLOBALS GOSUB "PG:Any Other"'  manually for GOSUB
  733. END IF
  734. END IF
  735. NEXT
  736. FN pGblackAndWhite
  737. END IF
  738. END FN
  739. '_______________________________________________________________________________
  740. LOCAL FN pGgetWTitle(theWindow)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  741. '—————————————————————————————————————————————————————————————————————————————
  742. gWindowTitle$ = ""
  743. LONG IF theWindow
  744. GET WINDOW theWindow ,wPtr&
  745. IF wPtr& THEN CALL GETWTITLE(wPtr&,gWindowTitle$)
  746. END IF
  747. END FN
  748. '_______________________________________________________________________________
  749. LOCAL FN pGcloseWindow(wndRefNum)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  750. '—————————————————————————————————————————————————————————————————————————————
  751. :'see if window exists
  752. LONG IF WINDOW(-wndRefNum) = 0 OR wndRefNum<1 OR wndRefNum>64
  753. FN pGshowErr(10)'show the error
  754. XELSE
  755. WINDOW OUTPUT wndRefNum
  756. gWhichClass = WINDOW(_outputWClass)
  757. gActWindow  = wndRefNum
  758. theCount = FN pGcountObj(gWhichClass)
  759. LONG IF theCount
  760. FOR loop = 1 TO theCount
  761. FN pGgetObj(gWhichClass,loop)
  762. LONG IF gObjKind = _buttonObj
  763. LONG IF gObjZType = 0
  764. gSubAction = _otherUserDispose'set flag to dispose obj
  765. gWhichObjElem = loop
  766. GLOBALS GOSUB "PG:Any Other"
  767. END IF
  768. END IF
  769. NEXT
  770. END IF
  771.  
  772. DIM pGwT,pGwL,pGwB,pGwR,pGwKind,pGwAttrs,pGwMinX,pGwMinY
  773. DIM pGwMaxX,pGwMaxY,pGZmT,pGZmL,pGZmB,pGZmR
  774. DIM pGwHpg,pGwHMax,pGwVpg,pGwVMax,pGwRefCon&
  775.  
  776. wTitle$ = FN pGgetWnd$(gWhichClass,@pGwT)
  777. LONG IF pGwAttrs AND _openPrevMask'€€ Open Previous €€€€€€€€€€€€
  778. pGwT;8 = WINDOW(_wndPointer)+_portRect'get local rect
  779. CALL LOCALTOGLOBAL(pGwT)'convert top/left to global
  780. CALL LOCALTOGLOBAL(pGwB)'convert bot/right to global
  781. FN pGputWnd(gWhichClass,@pGwT)'save these coords
  782. END IF'
  783. WINDOW CLOSE wndRefNum'close the window
  784. END IF
  785. FN pGcalcWndGlobals
  786. FN pGgetWTitle(gActWindow)
  787. END FN
  788. '_______________________________________________________________________________
  789. LOCAL FN pGclose(wndRefNum)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  790. '—————————————————————————————————————————————————————————————————————————————
  791. gDialogValue = wndRefNum
  792. GLOBALS GOSUB "PG:WCls"
  793. END FN
  794. '_______________________________________________________________________________
  795. LOCAL FN pGcloseAll'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  796. '—————————————————————————————————————————————————————————————————————————————
  797. OK2Close = _zTrue
  798. WHILE (WINDOW(_activeWnd)<>0) AND (gAction<>0)
  799. gDialogValue = WINDOW(_activeWnd)
  800. GLOBALS GOSUB"PG:WCls"
  801. OK2Close = (gAction <> 0)
  802. WEND
  803. END FN = OK2Close
  804. '_______________________________________________________________________________
  805. LOCAL FN pGbuild(wndRefNum)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  806. '—————————————————————————————————————————————————————————————————————————————
  807. DIM pGwT,pGwL,pGwB,pGwR,pGwKind,pGwAttrs,pGwMinX,pGwMinY
  808. DIM pGwMaxX,pGwMaxY,pGZmT,pGZmL,pGZmB,pGZmR
  809. DIM pGwHpg,pGwHMax,pGwVpg,pGwVMax,pGwRefCon&
  810. '
  811. DIM t,l,b,r'scratch rect
  812. DIM secndT,secndL,secndB,secndR'rect of secondary monitor
  813.  
  814. gWhichClass = ABS(wndRefNum)
  815.  
  816. LONG IF wndRefNum < 0
  817. FOR loop = 1 TO 64
  818. LONG IF WINDOW(-loop) = 0
  819. LONG IF FN GETRESOURCE(_"pG3w",loop) = 0
  820. wndRefNum = loop
  821. loop = 64
  822. END IF
  823. END IF
  824. NEXT
  825. END IF
  826.  
  827. LONG IF WINDOW(-wndRefNum)'already opened?
  828. WINDOW wndRefNum'bring it forward
  829. XELSE
  830. LONG IF FN GETRESOURCE(_"pG3w",gWhichClass) = 0
  831. FN pGshowErr(9):GOTO"PG:Build Complete"
  832. END IF
  833. wTitle$ = FN pGgetWnd$(gWhichClass,@pGwT)'get resource
  834. LONG IF wTitle$<>"ERROR"'got the resource?
  835. LONG IF pGwAttrs AND _openFullMask'€€ Full/Main €€€€€€€€€€€€€€€€
  836. pGwT;8 = @gScrnT'copy main screen rect
  837. FN pGinsetWnd(@pGwT,pGwKind,@pGwT)'adjust for title & borders
  838. END IF
  839. LONG IF pGwAttrs AND _openFull2Mask'€€ Full/Secondary €€€€€€€€€€€
  840. LONG IF SYSTEM(3)'mac plus (no device drvr)
  841. pGwT;8 = @gScrnT'just copy the main scrn
  842. XELSE'otherwise
  843. gdHndl& =FN GETDEVICELIST'handle to 1st device in list
  844. pGwT;8 = [gdHndl&]+_gdRect'get its rect
  845. LONG IF {[gdHndl&]+_gdflags} AND _mainScreen%'keep going-it's main scrn
  846. gdHndl& = FN GETNEXTDEVICE(gdHndl&)'get second scrn
  847. LONG IF gdHndl&'2nd device exists?
  848. pGwT;8 = [gdHndl&]+_gdRect'copy it's rect
  849. XELSE'otherwise
  850. pGwT;8 = @gScrnT'copy main screen rect
  851. END IF'end of valid device hndl
  852. END IF'end of not main scrn
  853. END IF'end of not a max plus
  854. FN pGinsetWnd(@pGwT,pGwKind,@pGwT)'inset wnd as per window kind
  855. END IF'done
  856. LONG IF pGwAttrs AND _openBigMask'€€ Full/Largest €€€€€€€€€€€€€
  857. LONG IF SYSTEM(3)'mac plus (no device drvr)
  858. pGwT;8 = @gScrnT'just copy the main scrn
  859. XELSE'otherwise
  860. pGwB = pGwT'any rect is larger than this
  861. gdHndl& = FN GETDEVICELIST'handle to 1st device in list
  862. DO'we'll run thru all devices
  863. LONG IF gdHndl&'good handle
  864. t;8 = [gdHndl&]+_gdRect'grab it's rect
  865. LONG IF ((b-t)*(r-l)) > ((pGwB-pGwT)*(pGwR-pGwL))
  866. pGwT;8 = @t'larger area - use this one
  867. END IF'
  868. END IF'
  869. gdHndl& = FN GETNEXTDEVICE(gdHndl&)'next graphic device in list
  870. UNTIL gdHndl& = 0'till there are no more
  871. END IF'dun
  872. FN pGinsetWnd(@pGwT,pGwKind,@pGwT)'allow for title/borders
  873. END IF'
  874. LONG IF pGwAttrs AND _openCntrMask'€€ Center €€€€€€€€€€€€€€€€€€€
  875. CALL OFFSETRECT(pGwT,-pGwL,-pGwT)'Basic centers if zero offset
  876. END IF'
  877. LONG IF pGwAttrs AND _openPrevMask'€€ Previous €€€€€€€€€€€€€€€€€
  878. LONG IF FN PTINRGN(pGwB,[_grayrgn])=_false'bot/right isn't visible?
  879. wd = gScrnR-gScrnL'width of main screen
  880. ht = gScrnB-gScrnT'height of main
  881. LONG IF pGwR - pGwL > wd'width won't fit?
  882. pGwR = gScrnR:pGwL = gScrnL'copy main screen rect
  883. t;8  = @pGwT'store old for restore of ht
  884. FN pGinsetWnd(@pGwT,pGwKind,@pGwT)'adjust for title & borders
  885. pGwT = t:pGwB = b'repair height to orig
  886. END IF'should be in position now
  887. LONG IF pGwB - pGwT > ht'height won't fit?
  888. pGwT = gScrnT:pGwB = gScrnB'copy main screen rect
  889. t;8  = @pGwT'store old for restore of wd
  890. FN pGinsetWnd(@pGwT,pGwKind,@pGwT)'adjust for title & borders
  891. pGwR = r:pGwL = l'repair width
  892. END IF'should be in position now
  893. IF pGwB > gScrnB THEN CALL OFFSETRECT(pGwT,0,gScrnB-pGwB)
  894. IF pGwR > gScrnR THEN CALL OFFSETRECT(pGwT,gScrnR-pGwR,0)
  895. END IF'end of bot/right invisible
  896. END IF
  897. LONG IF gWhichClass <> wndRefNum'€€ Build Class €€€€€€€€€€€€€€
  898. LONG IF pGwT OR pGwL'not centered
  899. chkWnd = 64'checking all windows
  900. WHILE chkWnd'until we hit zero
  901. GET WINDOW chkWnd,wPtr&'get this window
  902. LONG IF wPtr&'got a pointer?
  903. CALL SETPORT(wPtr&)'make it the current port
  904. `       MOVE.L  #0,^t               ;set point to 0,0
  905. CALL LOCALTOGLOBAL(t)'switch to global coords
  906. LONG IF pGwT = t OR pGwL = l'matches slot we want?
  907. CALL OFFSETRECT(pGwT,4,4)'offset to next position
  908. chkWnd = 64'restart at top of wnd list
  909. END IF'end of matched point
  910. END IF'end of valid wnd ptr
  911. DEC(chkWnd)'next (lower) window
  912. WEND'until checked wnd = 0
  913. END IF
  914. END IF'€€ Invisible €€€€€€€€€€€€€€€€
  915. LONG IF (pGwAttrs AND _openInvisMask) OR (pGwAttrs AND _openBehindMask)
  916. wndRefNum = -wndRefNum'open behind others
  917. END IF
  918. LONG IF SYSTEM(8) < 700'pre System 7.0
  919. IF pGwKind =  6 THEN pGwKind =  2'don't allow window type 6
  920. IF pGwKind = -6 THEN pGwKind = -2'not even modals
  921. END IF
  922. WINDOW wndRefNum,wTitle$,@pGwT,pGwKind,gWhichClass
  923. CALL SETRECT(t,-9999,-9999,9999,9999)
  924. CALL CLIPRECT(t)'€€ 03/30/93 €€
  925. FN pGblackAndWhite:CALL ERASERECT(t)
  926. LONG IF pGwHMax'window scroll bars
  927. SCROLL BUTTON 8000,1,1,pGwHMax,pGwHpg,,2'horiz scroll bar
  928. END IF
  929. ref = 0
  930. LONG IF pGwVMax
  931. LONG IF pGwAttrs AND 128
  932. FN pGdrawControls'draw the field in advance
  933. SCROLL BUTTON -8001,0,0,0,0,,1'vert scroll bar
  934. ref = -8001'use negative to hook in scroll
  935. CALL VALIDRECT(t)
  936. FN pGfixEditor
  937. XELSE
  938. ref = 8001'otherwise-standard V scroll
  939. SCROLL BUTTON ref,1,1,pGwVMax,pGwVpg,,1'vert scroll bar
  940. END IF
  941. END IF
  942. IF ref <> -8001 THEN FN pGdrawControls'ctrls for pg Wnds
  943. LONG IF pGwAttrs AND _openInvisMask'was in back
  944. LONG IF pGwRefCon& <> _"NVIS"'user didn't specify invisible
  945. WINDOW -wndRefNum'bring to front
  946. END IF
  947. END IF'
  948. LONG IF pGwAttrs AND _openBehindMask'was in back
  949. LONG IF pGwRefCon& <> _"NVIS"'user didn't specify invisible
  950. WINDOW OUTPUT wndRefNum'activate w/o bringing fwd
  951. END IF
  952. END IF
  953. LONG IF pGwAttrs AND 128'splash bit set
  954. LONG IF pGwVMax = 0'not a Text Editor
  955. FN pGupdate'don't wait for update event
  956. ticks& = FN TICKCOUNT + 140:flag =_false'calc time out:clear flag
  957. DO'loop till button,key or ticks
  958. IF FN BUTTON OR LEN(INKEY$) THEN flag = _zTrue
  959. LONG IF FN TICKCOUNT>ticks&'sufficient number of ticks?
  960. LONG IF gWhichClass = wndRefNum'window num was not negative?
  961. flag = _zTrue'time expired - exit
  962. END IF'
  963. END IF'
  964. UNTIL flag'
  965. % EVENT,0:FLUSHEVENTS'clear the event from the que
  966. WINDOW CLOSE ABS(wndRefNum)'close this feller
  967. END IF
  968. END IF
  969. END IF
  970. END IF
  971. "PG:Build Complete"
  972. FN pGcalcWndGlobals
  973. LONG IF gOutWindow
  974. CALL GETWTITLE(WINDOW(_wndPointer),gWindowTitle$)
  975. XELSE
  976. gWindowTitle$ = ""'clear related globals
  977. END IF
  978. END FN
  979. '_______________________________________________________________________________
  980. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ RUNTIME FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  981. '———————————————————————————————————————————————————————————————————————————————
  982. '_______________________________________________________________________________
  983. LOCAL FN pGmouse'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  984. '—————————————————————————————————————————————————————————————————————————————
  985. clickedObj = FN pGpointInObj
  986. LONG IF clickedObj
  987. FN pGgetObj(gWhichClass,clickedObj)
  988. LONG IF gObjKind = _buttonObj
  989. LONG IF gObjZType = 0
  990. gSubAction = _otherUserClick'tell user item was clicked
  991. gWhichObjElem = clickedObj
  992. GLOBALS GOSUB "PG:Any Other"
  993. END IF
  994. END IF
  995. END IF
  996. END FN
  997. '_______________________________________________________________________________
  998. LOCAL FN pGcursor'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  999. '—————————————————————————————————————————————————————————————————————————————
  1000. LONG IF WINDOW(_outputWnd) = DIALOG(_cursEvent)'correct window?
  1001. SELECT gWhichButton'same as gWhichField
  1002. CASE   <0:'show IBeam cursor
  1003. TEHndl& = TEHANDLE(ABS(gWhichButton))'if T=B then it's a pict
  1004. LONG IF {[TEHndl&]+_TEViewRect} = {[TEHndl&]+_TEViewRect.bottom}
  1005. CURSOR _pictCursor'over a pict field
  1006. XELSE
  1007. CURSOR _iBeamCursor'over a text field
  1008. END IF
  1009. CASE   >0:CURSOR _buttonCursor'use hand cursor
  1010. CASE ELSE:CURSOR _arrowCursor
  1011. END SELECT
  1012. XELSE'not in active window
  1013. CURSOR _arrowCursor'back to arrow
  1014. END IF'
  1015. END FN
  1016. '_______________________________________________________________________________
  1017. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ MENU FUNCTIONS €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  1018. '———————————————————————————————————————————————————————————————————————————————
  1019. '_______________________________________________________________________________
  1020. LOCAL FN pGfindMenu(theTitle$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1021. '—————————————————————————————————————————————————————————————————————————————
  1022. theMenu  = 0
  1023. mCount   = FN COUNTRESOURCES(_"MENU")
  1024. FOR thisMenu = 1 TO mCount
  1025. mHndl& = FN GETINDRESOURCE(_"MENU",thisMenu)
  1026. LONG IF mHndl&
  1027. LONG IF FN HOMERESFILE(mHndl&) = SYSTEM(_aplRes)
  1028. test$  = PSTR$([mHndl&] + _menuData)
  1029. LONG IF test$ = theTitle$
  1030. theMenu = {[mHndl&]}
  1031. thisMenu = mCount
  1032. END IF
  1033. END IF
  1034. END IF
  1035. NEXT
  1036. END FN = theMenu
  1037. '_______________________________________________________________________________
  1038. LOCAL FN pGfield(xLook,yLook)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1039. '—————————————————————————————————————————————————————————————————————————————
  1040. DIM srcT,srcL,srcB,srcR,destT;8
  1041. found = _false
  1042. srcT;8 = [TEHANDLE(gWhichField)]+_TEViewRect
  1043. objCount = FN pGcountObj(gWhichClass)
  1044. DO
  1045. CALL OFFSETRECT(srcT,xLook,yLook)
  1046. x = FN SECTRECT(srcT,#WINDOW(_wndPointer)+_portRect,destT)
  1047. LONG IF FN EQUALRECT(srcT,destT) = _false
  1048. found = _zTrue
  1049. XELSE
  1050. FOR loop = 1 TO objCount
  1051. FN pGgetObj(gWhichClass,loop)
  1052. LONG IF gObjKind = _styleObj
  1053. LONG IF gObjRef <> gWhichField
  1054. LONG IF ((gObjZType-1) AND &X1100)=0'not a static or gray field
  1055. LONG IF FN SECTRECT(srcT,gObjT,destT)
  1056. found = _zTrue
  1057. EDIT FIELD ABS(gObjRef)
  1058. END IF
  1059. END IF
  1060. END IF
  1061. END IF
  1062. NEXT
  1063. END IF
  1064. UNTIL found
  1065. END FN
  1066. '_______________________________________________________________________________
  1067. LOCAL FN pGtab(shiftDown)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1068. '—————————————————————————————————————————————————————————————————————————————
  1069. objCount = FN pGcountObj(gWhichClass)'object count for this wnd
  1070. LONG IF objCount'non zero?
  1071. dfltFld   = 0'default:nothing found
  1072. grabNext  = _false'don't record yet
  1073. LONG IF shiftDown'shift tab works in reverse
  1074. finish  = 1:start     = objCount'so run the loop backwards
  1075. theStep =-1'and step backwards
  1076. XELSE'otherwise
  1077. start   = 1:finish    = objCount'run loop forward thru list
  1078. theStep = 1'step is normal
  1079. END IF
  1080. FOR loop = start TO finish STEP theStep'loop thru all objs
  1081. FN pGgetObj(gWhichClass,loop)'get the next one
  1082. LONG IF gObjKind = _styleObj'a styled text field?
  1083.  
  1084. LONG IF ((gObjZType-1) AND &X1100)=0'not a static or gray field
  1085.  
  1086. LONG IF dfltFld = 0'default set yet?
  1087. dfltFld = gObjRef'no first item = wrap around
  1088. END IF
  1089.  
  1090. LONG IF grabNext'flag set to grab next?
  1091. dfltFld = gObjRef'yep-this is the field
  1092. loop    = finish'shortcut the loop
  1093. END IF
  1094.  
  1095. LONG IF gObjRef = gWhichField'this is the current field?
  1096. grabNext = _zTrue'yep-grab next one encountered
  1097. END IF
  1098.  
  1099. END IF'end of non-static field
  1100. END IF'end of styled text field
  1101. NEXT loop
  1102.  
  1103. LONG IF dfltFld'if we got one…
  1104. EDIT FIELD dfltFld'    set it
  1105. LONG IF WINDOW(_selStart) = WINDOW(_EFTextLen)
  1106. LONG IF WINDOW(_EFnum) < 8000
  1107. SETSELECT 0,WINDOW(_EFTextLen)
  1108. END IF
  1109. END IF
  1110. END IF
  1111. END IF
  1112. END FN
  1113. '_______________________________________________________________________________
  1114. LOCAL FN pGgetItemName$(menuID,itemID)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1115. '—————————————————————————————————————————————————————————————————————————————
  1116. mHndl& = FN GETMHANDLE(menuID)
  1117. LONG IF mHndl&
  1118. CALL GETITEM(mHndl&,itemID,theName$)
  1119. XELSE
  1120. theName$ = ""
  1121. END IF
  1122. END FN = theName$
  1123. '_______________________________________________________________________________
  1124. LOCAL FN pGcheckName(theMenu,theName$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1125. '—————————————————————————————————————————————————————————————————————————————
  1126. mHndl& = FN GETMHANDLE(theMenu)'handle to this menu
  1127. LONG IF mHndl&'valid handle?
  1128. itemCount = FN COUNTMITEMS(mHndl&)'number of items in menu
  1129. FOR loop = 1 TO itemCount'loop thru items
  1130. CALL GETITEM(mHndl&,loop,t$)'get name of item
  1131. LONG IF t$ = theName$'match?
  1132. DEF CHECKONEITEM(theMenu,loop)
  1133. loop = itemCount'skip the rest of the loop
  1134. END IF
  1135. NEXT
  1136. END IF
  1137. END FN
  1138. '_______________________________________________________________________________
  1139. CLEAR LOCAL'must clear pBlock
  1140. LOCAL FN pGopenFile'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1141. '—————————————————————————————————————————————————————————————————————————————
  1142. gFileName$ = FILES$(1,gOpenType$,,gFileVol)'standard files dialog
  1143. LONG IF PEEK(@gFileName$)'name <>""?
  1144. gSubAction = _mainOpen'set up message
  1145. pBlk&      = @paramBlk$'param Block to get file info
  1146. & pBlk& + _ioFDirIndex,0'clear to indicate op
  1147. & pBlk& + _ioNamePtr,@gFileName$'set up pointer to file name
  1148. % pBlk& + _ioVRefNum,gFileVol'set up vol number
  1149. OSErr      = FN GETFILEINFO(pBlk&)'get finder info on this file
  1150. gFileType& = [pBlk& + _ioBuffer]'get file type
  1151. fdFlags    = {pBlk& + _ioBuffer_fdflags}'get finder flags
  1152. gIsStationery = ((fdFlags AND 2048)<>0)'check stationery bit
  1153. GLOBALS GOSUB "PG:Any Main"'send it to program
  1154. END IF
  1155. END FN
  1156. '_______________________________________________________________________________
  1157. LOCAL FN pGsaveAs'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1158. '—————————————————————————————————————————————————————————————————————————————
  1159. LONG IF LEN(gSaveName$)'file name exists?
  1160. t$ = gSaveName$'use it
  1161. XELSE'otherwise
  1162. t$ = "Untitled Document"'use a default name
  1163. END IF
  1164. t$ = FILES$(0,"Save document as…",t$,vol)'standard files
  1165. LONG IF LEN(t$)'SF wasn't canceled?
  1166. gSaveName$ = t$'file name into global
  1167. gSaveVol   = vol'vol ref into global
  1168. boolean    = _zTrue'success-set flag
  1169. XELSE'save was canceled
  1170. boolean    = _false'failure-clear flag
  1171. END IF
  1172. END FN = boolean
  1173. '_______________________________________________________________________________
  1174. LOCAL FN pGautoMenu(menuID,itemID)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1175. '—————————————————————————————————————————————————————————————————————————————
  1176. mHndl& = FN GETMHANDLE(menuID)
  1177. LONG IF mHndl&
  1178. theTitle$ = PSTR$([mHndl&] + _menuData)
  1179. CALL GETITEM(mHndl&,itemID,theItem$)
  1180. LONG IF theTitle$ = STR#(_baseID - 2,1)'== FILE MENU ==
  1181. t$ = STR#(_baseID - 2,2)'special allowances for open
  1182. l = LEN(t$)'addn'l chars added by
  1183. LONG IF l
  1184. IF LEFT$(theItem$,l) = t$ THEN theItem$ = t$'       Boomerang
  1185. END IF
  1186. SELECT theItem$
  1187. CASE STR#(_baseID - 2,2)'"Open" item
  1188. FN pGopenFile
  1189. CASE STR#(_baseID - 2,4)'"Page Setup…" item
  1190. DEF PAGE
  1191. CASE STR#(_baseID - 2,5)'"Close" item
  1192. LONG IF WINDOW(_activeWnd)
  1193. gDialogValue = WINDOW(_activeWnd)
  1194. GLOBALS GOSUB"PG:WCls"
  1195. END IF
  1196. CASE STR#(_baseID - 2,6)'"Quit" item
  1197. GLOBALS GOSUB"PG:Break"
  1198. CASE STR#(_baseID - 2,3)'"Save" item
  1199. boolean = _zTrue
  1200. LONG IF LEN(gSaveName$) = 0 OR gSaveVol = 0
  1201. boolean = FN pGsaveAs
  1202. END IF
  1203. LONG IF boolean
  1204. gSubAction = _mainSave
  1205. gDirty = _false
  1206. GLOBALS GOSUB"PG:Any Main"
  1207. END IF
  1208. CASE STR#(_baseID - 2,7)'"Save As…" item
  1209. boolean = FN pGsaveAs
  1210. LONG IF boolean
  1211. gSubAction = _mainSave
  1212. gDirty = _false
  1213. GLOBALS GOSUB"PG:Any Main"
  1214. END IF
  1215. END SELECT
  1216. END IF
  1217. END IF
  1218. END FN
  1219. '_______________________________________________________________________________
  1220. LOCAL FN pGfixMenus'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1221. '—————————————————————————————————————————————————————————————————————————————
  1222. IF FN BUTTON THEN CURSOR _arrowCursor
  1223. t$ = STR#(_baseID - 2,1)'get name of File menu
  1224. LONG IF LEN(t$)
  1225. fileMenu = FN pGfindMenu(t$)
  1226. LONG IF fileMenu
  1227. mHndl& = FN GETMHANDLE(fileMenu)
  1228. LONG IF mHndl&
  1229. saveName$   = STR#(_baseID - 2,3)'name of Save item
  1230. saveAsName$ = STR#(_baseID - 2,7)'name of Save As… item
  1231. printItem$  = STR#(_baseID - 2,8)'name of print item
  1232. itemCount   = FN COUNTMITEMS(mHndl&)
  1233. FOR loop = 1 TO itemCount
  1234. CALL GETITEM(mHndl&,loop,t$)
  1235. SELECT t$
  1236. CASE saveName$
  1237. MENU fileMenu,loop,ABS(gDirty<>0)'enable if dirty
  1238. IF WINDOW(_activeWnd) = 0 THEN MENU fileMenu,loop,0
  1239. CASE saveAsName$
  1240. MENU fileMenu,loop,ABS(LEN(gSaveName$)>0)'enable if file open
  1241. IF WINDOW(_activeWnd) = 0 THEN MENU fileMenu,loop,0
  1242. CASE printName$
  1243. MENU fileMenu,loop,ABS(WINDOW(_activeWnd)<>0)
  1244. END SELECT
  1245. NEXT
  1246. END IF
  1247. END IF
  1248. END IF
  1249. END FN
  1250. '_______________________________________________________________________________
  1251. LOCAL FN pGopenDoc'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1252. '—————————————————————————————————————————————————————————————————————————————
  1253. fileIndex = {[gFileList&]+2}
  1254. % [gFileList&]+2,fileIndex - 1
  1255. offSet = 4
  1256.  
  1257. LONG IF fileIndex > 1
  1258. FOR loop = 1 TO fileIndex - 1
  1259. offSet = offSet + 8
  1260. lgth = PEEK([gFileList&]+offSet) + 1
  1261. lgth = (lgth + 1) AND &FE
  1262. offSet=offSet+lgth
  1263. NEXT
  1264. END IF
  1265.  
  1266. gSubAction = {[gFileList&]} + 2'_mainOpen or _mainPrint
  1267. gFileVol   = {[gFileList&]+offSet}
  1268. gFileType& = [[gFileList&]+offSet+2]
  1269. gFileName$ = PSTR$([gFileList&]+offSet+8)
  1270.  
  1271. IF fileIndex = 1 THEN DEF DISPOSEH(gFileList&)
  1272.  
  1273. GLOBALS GOSUB "PG:Any Main"
  1274. END FN
  1275. '_______________________________________________________________________________
  1276. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ RUNTIME INIT €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  1277. '———————————————————————————————————————————————————————————————————————————————
  1278. '_______________________________________________________________________________
  1279. LOCAL FN pGinitRuntime'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1280. '—————————————————————————————————————————————————————————————————————————————
  1281. gEventPtr&   = EVENT'event rec never moves
  1282. IF SYSTEM(8) > 599 THEN & EVENT-8,1'WNE 60 times/sec(Sys.6.0 & up)
  1283. gResRef      = SYSTEM(4)'current resource reference
  1284. gScrnR       = SYSTEM(6)'screen width
  1285. gScrnB       = SYSTEM(7)'screen height
  1286. gScrnT       = {_mBarHeight}'allow for menu bar
  1287. gScreenDepth = SYSTEM(11)'max colors
  1288. CALL SETRECT(gBigT,-9999,-9999,9999,9999)'generic big rect
  1289.  
  1290. curRes = FN CURRESFILE'record curres file
  1291. CALL USERESFILE(gResRef)'switch to app's file
  1292. theCount = FN COUNT1RESOURCES(_"MENU")'how many menus?
  1293. WHILE theCount'more to go?
  1294. resHndl& = FN GET1INDRESOURCE(_"MENU",theCount)'get next menu
  1295. LONG IF resHndl&'valid handle?
  1296. menuID = {[resHndl&]}'get its ID
  1297. LONG IF menuID > 74 AND menuID < 100'74> Sub menus <100
  1298. MENU menuID,-2,1'insert it
  1299. END IF
  1300. END IF
  1301. DEC(theCount)'decrement index
  1302. WEND
  1303. CALL USERESFILE(curRes)
  1304.  
  1305. LONG IF SYSTEM(8) > 699'System 7.0 or later
  1306. LONG IF FN GESTALT(_gestaltAppleEventsAttr) AND SYSERROR = 0
  1307. OSErr = FN AEINSTALLEVENTHANDLER(_typeAppleEvent,_kAEOpenApplication,LINE"PG:AE Open App",0,_false)
  1308. OSErr = FN AEINSTALLEVENTHANDLER(_typeAppleEvent,_kAEOpenDocuments  ,LINE"PG:AE Open Doc",0,_false)
  1309. OSErr = FN AEINSTALLEVENTHANDLER(_typeAppleEvent,_kAEPrintDocuments ,LINE"PG:AE Print Doc",0,_false)
  1310. OSErr = FN AEINSTALLEVENTHANDLER(_typeAppleEvent,_kAEQuitApplication,LINE"PG:AE Quit App",0,_false)
  1311. END IF
  1312. END IF
  1313.  
  1314. LONG IF [_appParmHandle]
  1315. LONG IF {[[_appParmHandle]]+2}
  1316. LONG IF SYSTEM(_aplFlag)
  1317. gFileList& = FN HANDTOHAND([_appParmHandle])
  1318. END IF
  1319. END IF
  1320. END IF
  1321.  
  1322. DIM pGwT,pGwL,pGwB,pGwR,pGwKind,pGwAttrs,pGwMinX,pGwMinY
  1323. DIM pGwMaxX,pGwMaxY,pGZmT,pGZmL,pGZmB,pGZmR
  1324. DIM pGwHpg,pGwHMax,pGwVpg,pGwVMax,pGwRefCon&
  1325.  
  1326. theCount = FN COUNTRESOURCES(_"pG3w")'look for splash windows
  1327. FOR loop = 1 TO theCount
  1328. resHndl& = FN GETINDRESOURCE(_"pG3w",loop)
  1329. LONG IF resHndl&
  1330. BLOCKMOVE [resHndl&],@pGwT,FN GETHANDLESIZE(resHndl&)
  1331. LONG IF pGwVMax = 0
  1332. LONG IF pGwAttrs AND 128
  1333. CALL GETRESINFO(resHndl&,ID,tp&,t$)
  1334. FN pGbuild(ID)
  1335. loop = theCount
  1336. END IF
  1337. END IF
  1338. END IF
  1339. NEXT
  1340.  
  1341. GLBLask&       = @FN pGask$          :GLBLautoMenu&  = @FN pGautoMenu
  1342. GLBLBlkNWhite& = @FN pGblackAndWhite :GLBLbtnAction& = @FN pGbtnAction
  1343. GLBLbuild&     = @FN pGbuild         :GLBLcheckName& = @FN pGcheckName
  1344. GLBLclose&     = @FN pGclose         :GLBLcloseAll&  = @FN pGcloseAll
  1345. GLBLcntrRes&   = @FN pGcntrRes       :GLBLcountObj&  = @FN pGcountObj
  1346. GLBLcursor&    = @FN pGcursor        :GLBLdrwCtrls&  = @FN pGdrawControls
  1347. GLBLfield&     = @FN pGfield         :GLBLfindMenu&  = @FN pGfindMenu
  1348. GLBLfixEditor& = @FN pGfixEditor     :GLBLfixMenus&  = @FN pGfixMenus
  1349. GLBLframeBtn&  = @FN pGframeBtn      :GLBLgetGroup&  = @FN pGgetGroup
  1350. GLBLgetIName&  = @FN pGgetItemName$  :GLBLgetObj&    = @FN pGgetObj
  1351. GLBLgetRef&    = @FN pGgetRef        :GLBLgetText&   = @FN pGgetText$
  1352. GLBLgetWnd&    = @FN pGgetWnd$       :GLBLgetWTitle& = @FN pGgetWTitle
  1353. GLBLinitRntm&  = @FN pGinitRuntime   :GLBLinsetWnd&  = @FN pGinsetWnd
  1354. GLBLmouse&     = @FN pGmouse         :GLBLopenDoc&   = @FN pGopenDoc
  1355. GLBLopenFile&  = @FN pGopenFile      :GLBLptInObj&   = @FN pGpointInObj
  1356. GLBLputObj&    = @FN pGputObj        :GLBLputWnd&    = @FN pGputWnd
  1357. GLBLrepRes&    = @FN pGreplaceRes    :GLBLrepXRes&   = @FN pGreplaceXRes
  1358. GLBLsaveAs&    = @FN pGsaveAs        :GLBLsetGroup&  = @FN pGsetGroup
  1359. GLBLsetGrow&   = @FN pGsetGrow       :GLBLsetZoom&   = @FN pGsetZoom
  1360. GLBLshowErr&   = @FN pGshowErr       :GLBLtab&       = @FN pGtab
  1361. GLBLupdate&    = @FN pGupdate        :GLBLuseObjClr& = @FN pGuseObjColor
  1362. GLBLpntDpth&   = @FN pGdepthOfPoint
  1363.  
  1364. END FN
  1365. '_______________________________________________________________________________
  1366. CLEAR LOCAL'must clear pBlk & noName$
  1367. LOCAL FN pGAEDocList'›fi› 01/15/92 ›fi›
  1368. '—————————————————————————————————————————————————————————————————————————————
  1369. DIM AEDesc&;0,descriptorType&,dataHandle&
  1370. DIM fsSpec;0,fsVRefNum,fsParID&,63 fsName$
  1371. maxSize& = @maxSize& - @fsSpec
  1372.  
  1373. LONG IF FN AEGETPARAMDESC(gEventPtr&,_keyDirectObject,_typeAEList,AEDesc&)= 0
  1374. LONG IF FN AECOUNTITEMS(AEDesc&,theCount&) = 0
  1375. FOR loop = 1 TO theCount&
  1376. LONG IF FN AEGETNTHPTR(AEDesc&,loop,_typeFSS,keyWord&,rtnType&,@fsSpec,maxSize&,actualSize&) = 0
  1377. gFileName$ = fsName$'record name from FS rec
  1378. pBlk&      = @paramBlk$'chg WrkDirID to vRefNum
  1379. % pBlk& + _ioVRefNum ,fsVRefNum'volume ref num
  1380. & pBlk& + _ioWDDirID ,fsParID&'set par ID in pblock
  1381. OSErr      = FN OPENWD(pBlk&)'open this path
  1382. gFileVol   = {pBlk& + _ioVRefNum}'get volRef num
  1383. & pBlk& + _ioFDirIndex,0'clear dir index to indicate op
  1384. & pBlk& + _ioNamePtr,@fsName$'set up pointer to file name
  1385. OSErr      = FN GETFILEINFO(pBlk&)'get finder info on this file
  1386. gFileType& = [pBlk& + _ioBuffer]'get file type
  1387. fdFlags    = {pBlk& + _ioBuffer_fdflags}'get finder flags
  1388. gIsStationery = ((fdFlags AND 2048)<>0)'check stationery bit
  1389. GLOBALS GOSUB "PG:Any Main"
  1390. END IF
  1391. DEF BLOCKFILL(pBlk&,250,0)' ∑∑ 8/13/93 ∑∑
  1392. NEXT
  1393. END IF
  1394. OSErr = FN AEDISPOSEDESC(AEDesc&)
  1395. END IF
  1396. END FN
  1397. '_______________________________________________________________________________
  1398. "PG:AE Open App"'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1399. '———————————————————————————————————————————————————————————————————————————————
  1400. ENTERPROC(gEventPtr&,gEventPtr&,gWhichRefCon&)
  1401. :'do nothing
  1402. gMessage1 = 0
  1403. EXITPROC = gMessage1
  1404. RETURN
  1405. '_______________________________________________________________________________
  1406. "PG:AE Quit App"'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1407. '———————————————————————————————————————————————————————————————————————————————
  1408. ENTERPROC(gEventPtr&,gEventPtr&,gWhichRefCon&)
  1409. GLOBALS GOSUB "PG:Break"
  1410. gMessage1 = 0
  1411. EXITPROC = gMessage1
  1412. RETURN
  1413. '_______________________________________________________________________________
  1414. "PG:AE Print Doc"'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1415. '———————————————————————————————————————————————————————————————————————————————
  1416. ENTERPROC(gEventPtr&,gEventPtr&,gWhichRefCon&)
  1417. gSubAction = _mainPrint
  1418. FN pGAEDocList
  1419. gMessage1 = 0
  1420. EXITPROC = gMessage1
  1421. RETURN
  1422. '_______________________________________________________________________________
  1423. "PG:AE Open Doc"'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  1424. '———————————————————————————————————————————————————————————————————————————————
  1425. ENTERPROC(gEventPtr&,gEventPtr&,gWhichRefCon&)
  1426. gSubAction = _mainOpen
  1427. FN pGAEDocList
  1428. gMessage1 = 0
  1429. EXITPROC = gMessage1
  1430. RETURN
  1431. '_______________________________________________________________________________
  1432. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ RUNTIME PACKAGE €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  1433. '———————————————————————————————————————————————————————————————————————————————
  1434. "PG:Start"
  1435. FN pGinitRuntime'handle my startup
  1436. ON BREAK      GOSUB "PG:Chk Break"'go here for command-period
  1437. ON DIALOG     GOSUB "PG:Dialog"'use this routine for dialog
  1438. ON EDIT       GOSUB "PG:TEKey"'filter keys for edit flds
  1439. ON EVENT      GOSUB "PG:Event"'pre-event filter
  1440. ON MENU       GOSUB "PG:Menu"'menu handlers
  1441. ON MOUSE      GOSUB "PG:Mouse"'mouse handler
  1442. ON TIMER(-10) GOSUB "PG:Timer"'ZTimer (30 ticks=1/2 second)
  1443. ON STOP       GOSUB "PG:Stop"
  1444. '-------------------------------------------------------------------------------
  1445. gSubAction =_mainStart'let user init
  1446. GOSUB "PG:Any Main"
  1447. '-------------------------------------------------------------------------------
  1448. DO
  1449. MENU ON  : DIALOG ON  : BREAK ON  : MOUSE ON  : TIMER ON  : EVENT ON
  1450. MENU OFF : DIALOG OFF : BREAK OFF : MOUSE OFF : TIMER OFF : EVENT OFF
  1451. IF gKissOfDeath THEN GOSUB"PG:Break"
  1452. UNTIL 0
  1453. '-------------------------------------------------------------------------------
  1454. "PG:Menu"
  1455. '-------------------------------------------------------------------------------
  1456. gAction    = _MenuAction'action constant
  1457. gWhichMenu = MENU(_menuID)'selected menu
  1458. gWhichItem = MENU(_itemID)'selected item
  1459. gItemName$ = FN pGgetItemName$(gWhichMenu,gWhichItem)'get name of this item
  1460. GOSUB "PG:Send Event"'send event to user
  1461. MENU'unhilite the menu
  1462. IF gAction THEN FN pGautoMenu(gWhichMenu,gWhichItem)
  1463. RETURN'done
  1464. '-------------------------------------------------------------------------------
  1465. "PG:Dialog"
  1466. '-------------------------------------------------------------------------------
  1467. gWhichDialog = DIALOG(0)'dialog action
  1468. gDialogValue = DIALOG(gWhichDialog)'dialog reference
  1469. ON gWhichDialog      GOTO "PG:Btn" ,"PG:EAct","PG:WClk","PG:WCls" ,"PG:WUpd"
  1470. ON gWhichDialog -  5 GOTO "PG:ERet","PG:ETab","PG:NOP" ,"PG:NOP"  ,"PG:EStb"
  1471. ON gWhichDialog - 10 GOTO "PG:EClr","PG:ELft","PG:ERt" ,"PG:EUp"  ,"PG:EDn"
  1472. ON gWhichDialog - 15 GOTO "PG:Key" ,"PG:Dsk" ,"PG:WAct","PG:MFevt","PG:Gcrs"
  1473. ON gWhichDialog - 20 GOTO "PG:Crsr","PG:Abt" ,"PG:Usr"
  1474. RETURN
  1475. '===============================================================================
  1476. "PG:Btn"'(1) Button clicked
  1477. gAction      = _buttonAction'action constant
  1478. gWhichButton = gDialogValue'clicked button
  1479. gWhichClass  = WINDOW(_outputWClass)
  1480. FN pGbtnAction(gWhichButton)
  1481. gWhichObjElem= FN pGgetRef(gWhichClass,gWhichButton)'get btn's obj record
  1482. gButtonValue = BUTTON(gWhichButton)'current btn value
  1483. gControlHndl&= BUTTON&(gWhichButton)'get control's handle
  1484. LONG IF (FN GETCREFCON(gControlHndl&)>>29) = 4'ZBasic scroll bar?
  1485. gControlTitle$ = STR#(_baseID-5,4)'send "Scroll Button" as title
  1486. XELSE'not a scroll bar?
  1487. CALL GETCTITLE(gControlHndl&,gControlTitle$)'send control's title
  1488. END IF
  1489. GOTO "PG:Send Event"
  1490. RETURN
  1491. '===============================================================================
  1492. "PG:WClk"'(5) Inactive Window Clicked
  1493. gSubAction   = _windowClicked'sub action:click in inactive
  1494. gWhichWindow = gDialogValue'window clicked
  1495. GOSUB "PG:Any Window"'send wnd msg(sets action _con)
  1496. LONG IF gAction'not handled by user?
  1497. IF gWhichWindow THEN WINDOW gWhichWindow'I'll do the switch
  1498. END IF
  1499. RETURN
  1500. '-------------------------------------------------------------------------------
  1501. "PG:WCls"'(4) Click in close box
  1502. gSubAction   = _windowClose'subaction constant
  1503. gWhichWindow = gDialogValue
  1504. PUSH WORD(@gWhichWindow)' ∑∑ 10/25/93 ∑∑
  1505. GOSUB "PG:Any Window"'send wnd msg(sets action _con)
  1506. POP WORD(@gWhichWindow)' ∑∑ 10/25/93 ∑∑
  1507. LONG IF gAction'not handled by user?
  1508. FN pGcloseWindow(gWhichWindow)'I'll close it
  1509. END IF
  1510. RETURN
  1511. '-------------------------------------------------------------------------------
  1512. "PG:WAct"'(18) activate/deactivate
  1513. gWhichWindow = ABS(gDialogValue)
  1514. LONG IF gDialogValue > 0
  1515. gSubAction =_windowActivate' positive = activate
  1516. XELSE' negative = deactivate
  1517. gSubAction =_windowDeactivate
  1518. END IF
  1519. GOTO "PG:Any Window"'send wnd msg(sets action _con)
  1520. RETURN
  1521. '-------------------------------------------------------------------------------
  1522. "PG:WUpd"'(5) update
  1523. gWhichWindow = gDialogValue
  1524. gSubAction   = _windowUpdate
  1525. gOutputWas   = WINDOW(_outputWnd)
  1526. WINDOW OUTPUT gWhichWindow
  1527. GOSUB "PG:Any Window"
  1528. IF gAction THEN FN pGupdate
  1529. IF gOutputWas THEN WINDOW OUTPUT gOutputWas
  1530. RETURN
  1531. '-------------------------------------------------------------------------------
  1532. "PG:NOP"'No Operation
  1533. RETURN
  1534. '===============================================================================
  1535. "PG:EAct"'(2) Edit/Pict field Clicked
  1536. gSubAction = _fieldActivate
  1537. gFieldWas  = WINDOW(_lastEFnum)
  1538. GOTO "PG:Any Field"
  1539. RETURN
  1540. '-------------------------------------------------------------------------------
  1541. "PG:ERet"'(6) Return key in field
  1542. gSubAction = _fieldReturn
  1543. GOTO "PG:Any Field"
  1544. RETURN
  1545. '-------------------------------------------------------------------------------
  1546. "PG:ETab"'(7) Tab Key pressed
  1547. gSubAction = _fieldTab
  1548. GOSUB "PG:Any Field"
  1549. IF gAction THEN FN pGtab(_false)
  1550. RETURN
  1551. '-------------------------------------------------------------------------------
  1552. "PG:EStb"'(10) shift tab pressed
  1553. gSubAction = _fieldShiftTab
  1554. GOSUB "PG:Any Field"
  1555. IF gAction THEN FN pGtab(_zTrue)
  1556. RETURN
  1557. '-------------------------------------------------------------------------------
  1558. "PG:EClr"'(11) clear key pressed
  1559. gSubAction = _fieldClear
  1560. GOSUB "PG:Any Field"
  1561. IF gAction THEN EDIT FIELD gObjRef,""
  1562. RETURN
  1563. '-------------------------------------------------------------------------------
  1564. "PG:ELft"'(12) left arrow pressed
  1565. gSubAction = _fieldLeft
  1566. GOSUB "PG:Any Field"
  1567. IF gAction THEN FN pGfield(-10,0)
  1568. RETURN
  1569. '-------------------------------------------------------------------------------
  1570. "PG:ERt"'(13) right arrow pressed
  1571. gSubAction = _fieldRight
  1572. GOSUB "PG:Any Field"
  1573. IF gAction THEN FN pGfield(10,0)
  1574. RETURN
  1575. '-------------------------------------------------------------------------------
  1576. "PG:EUp"'(14) up arrow pressed
  1577. gSubAction = _fieldUp
  1578. GOSUB "PG:Any Field"
  1579. IF gAction THEN FN pGfield(0,-10)
  1580. RETURN
  1581. '-------------------------------------------------------------------------------
  1582. "PG:EDn"'(15) down arrow pressed
  1583. gSubAction = _fieldDown
  1584. GOSUB "PG:Any Field"
  1585. IF gAction THEN FN pGfield(0,10)
  1586. RETURN
  1587. '-------------------------------------------------------------------------------
  1588. "PG:Any Field"'branch sets action constant
  1589. gAction       = _fieldAction
  1590. gWhichField   = gDialogValue
  1591. gWhichObjElem = FN pGgetRef(WINDOW(_outputWClass),gWhichField)'get field's obj record
  1592. FN pGgetObj(WINDOW(_outputWClass),gWhichObjElem)
  1593. GOTO "PG:Send Event"
  1594. RETURN
  1595. '===============================================================================
  1596. "PG:Key"'(16) Key Presed Not in Field
  1597. gKey$ = CHR$(gDialogValue)
  1598. gSubAction = _otherKeyPressed
  1599. GOTO "PG:Any Other"
  1600. RETURN
  1601. '-------------------------------------------------------------------------------
  1602. "PG:Dsk"'(17) Disk Inserted
  1603. gSubAction = _otherDisk
  1604. GOSUB "PG:Any Other"
  1605. IF gAction THEN FN pGopenFile
  1606. RETURN
  1607. '-------------------------------------------------------------------------------
  1608. "PG:MFevt"'(19) MultiFinder Event
  1609. SELECT gDialogValue
  1610. CASE _MFResume'resume
  1611. gSubAction = _otherSwitch
  1612. gInBackground = _false
  1613. FLUSHEVENTS
  1614. CASE _MFSuspend'suspend
  1615. gSubAction = _otherSwitch
  1616. gInBackground = _zTrue
  1617. CASE _MFClipboard'convert scrap
  1618. gSubAction = _otherScrap
  1619. gInBackground = _false
  1620. CASE _MFMouse'mouse moved from MF region
  1621. gSubAction = _otherCursor
  1622. END SELECT
  1623. GOTO "PG:Any Other"
  1624. RETURN
  1625. '-------------------------------------------------------------------------------
  1626. "PG:Gcrs"'(20) New Global Mouse Position
  1627. gSubAction = _otherCursor
  1628. GOSUB "PG:Any Other"'send to user
  1629. LONG IF gAction'not handled?
  1630. CURSOR _arrowCursor'back to arrow
  1631. END IF
  1632. RETURN
  1633. '-------------------------------------------------------------------------------
  1634. "PG:Crsr"'(21) New Cursor Pos in Window
  1635. gWhichButton = gDialogValue
  1636. gSubAction = _otherCursor
  1637. GOSUB "PG:Any Other"'send to user
  1638. LONG IF gAction'not handled?
  1639. FN pGcursor
  1640. END IF
  1641. RETURN
  1642. '-------------------------------------------------------------------------------
  1643. "PG:Abt"'(22) About to ???
  1644. SELECT CASE gDialogValue
  1645. CASE _premenuclick'mouse in bar or cmnd key
  1646. FN pGfixMenus
  1647. gSubAction = _otherBeforeMenu
  1648. GOSUB "PG:Any Other"'send to user
  1649. CASE _preWndGrow'mouse in grow box
  1650. gSubAction   = _WindowWillGrow
  1651. gWhichWindow = WINDOW(_activeWnd)
  1652. GOSUB "PG:Any Window"
  1653. LONG IF gAction
  1654. FN pGsetGrow
  1655. END IF
  1656. CASE _wndMoved'already did a drag
  1657. gSubAction   = _windowMoved
  1658. gWhichWindow = WINDOW(_activeWnd)
  1659. GOSUB "PG:Any Window"
  1660. CASE _wndSized'after grow
  1661. gWhichWindow = WINDOW(_activeWnd)
  1662. gSubAction   = _windowSized
  1663. GOSUB "PG:Any Window"
  1664. LONG IF gAction
  1665. FN pGfixEditor
  1666. END IF
  1667. CASE 5'field about to change
  1668. gSubAction = _fieldChanging
  1669. gDialogValue = WINDOW(_EFnum)
  1670. GOSUB "PG:Any Field"
  1671. CASE 6'field clicked
  1672. gSubAction = _fieldClicked
  1673. gDialogValue = WINDOW(_EFnum)
  1674. GOSUB "PG:Any Field"
  1675. CASE _preWndZoomIn'about to zoom in
  1676. gSubAction   = _windowWillZoomIn
  1677. gWhichWindow = WINDOW(_activeWnd)
  1678. GOSUB "PG:Any Window"
  1679. CASE _preWndZoomOut'about to zoom out
  1680. gSubAction   = _windowWillZoomOut
  1681. gWhichWindow = WINDOW(_activeWnd)
  1682. GOSUB "PG:Any Window"
  1683. IF gAction THEN FN pGsetZoom
  1684. CASE _wndDocWillMove'background window will move
  1685. gSubAction   = _windowDocWillMove
  1686. gWhichWindow = WINDOW(_outputWnd)
  1687. GOSUB "PG:Any Window"
  1688. END SELECT
  1689. RETURN
  1690. '-------------------------------------------------------------------------------
  1691. "PG:Usr"'(23) User Posted Event
  1692. LONG IF gDialogValue < 0
  1693. FN pGshowErr(EVENT%)'field or other error
  1694. RETURN
  1695. XELSE
  1696. gSubAction = _otherUser
  1697. GOTO "PG:Any Other"
  1698. END IF
  1699. '===============================================================================
  1700. "PG:Chk Break" IF _ignoreCmndPeriod THEN RETURN'command period pressed
  1701. "PG:Break"'called to exit
  1702. gSubAction = _mainShutDown
  1703. gKissOfDeath = _zTrue
  1704. GOSUB "PG:Any Main"'ask user to shutdown
  1705. LONG IF gAction'user didn't abort close
  1706. LONG IF FN pGcloseAll'could we close all windows
  1707. END'we're outta here
  1708. END IF
  1709. END IF
  1710. gKissOfDeath = _false
  1711. RETURN
  1712. '===============================================================================
  1713. "PG:Stop"
  1714. DEF DISPOSEH(gFileList&)
  1715. RETURN
  1716. '===============================================================================
  1717. "PG:Mouse"
  1718. gAction      = _mouseAction
  1719. gClickStatus = MOUSE(0)
  1720. gMouseX      = MOUSE(1)
  1721. gMouseY      = MOUSE(2)
  1722. gModifiers   = EVENT%
  1723. gWhen&       = EVENT&
  1724. gWhereY;4    = @gMouseY
  1725. CALL LOCALTOGLOBAL(gWhereY)
  1726. GOSUB "PG:Send Event"
  1727. IF gAction THEN FN pGmouse
  1728. RETURN
  1729. '===============================================================================
  1730. "PG:Timer"
  1731. gSubAction = _mainTimer
  1732. GOTO "PG:Any Main"
  1733. RETURN
  1734. '===============================================================================
  1735. "PG:TEKey"
  1736. gKey$        = TEKEY$
  1737. gSubAction   = _fieldKeyPressed
  1738. gDialogValue = WINDOW(_EFnum)
  1739. gWhichField  = gDialogValue
  1740. GOSUB "PG:Any Field"
  1741. LONG IF gAction
  1742. LONG IF gKey$ = CHR$(127)
  1743. gKey$  = CHR$(29) + CHR$(8)
  1744. END IF
  1745. TEKEY$ = gKey$
  1746. END IF
  1747. RETURN
  1748. '===============================================================================
  1749. "PG:Event"
  1750. gAction = _otherAction
  1751. gWhat;_evtBlkSize = EVENT
  1752. LONG IF {EVENT}
  1753. gSubAction = _otherFilterEvent
  1754. XELSE
  1755. LONG IF gFileList&
  1756. FN pGopenDoc:RETURN
  1757. XELSE
  1758. gSubAction = _otherNullEvent
  1759. END IF
  1760. END IF
  1761. GOSUB "PG:Main Program"
  1762. LONG IF {EVENT}=_updatEvt
  1763. LONG IF gAction > 0
  1764. gWhichClass = WINDOW(_outputWClass)
  1765. FN pGblackAndWhite
  1766. END IF
  1767. END IF
  1768. RETURN
  1769. '_______________________________________________________________________________
  1770. '€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€  MAIN  €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
  1771. '———————————————————————————————————————————————————————————————————————————————
  1772. "PG:Any Window"
  1773. gAction = _windowAction
  1774. FN pGgetWTitle(gWhichWindow)'get title of this window
  1775. GOTO "PG:Send Event"
  1776. RETURN
  1777. '-------------------------------------------------------------------------------
  1778. "PG:Any Main"
  1779. gAction = _mainAction
  1780. GOTO "PG:Send Event"
  1781. RETURN
  1782. '-------------------------------------------------------------------------------
  1783. "PG:Any Other"
  1784. gAction = _otherAction
  1785. '-------------------------------------------------------------------------------
  1786. "PG:Send Event"
  1787. FN pGcalcWndGlobals
  1788. '-------------------------------------------------------------------------------
  1789. '*******************************************************************************
  1790. "PG:Main Program"
  1791. '*******************************************************************************
  1792.  
  1793.